package net.peelmeagrape.hibernate.collections;

import net.peelmeagrape.hibernate.xmlgen.XmlAttribute;
import net.peelmeagrape.hibernate.xmlgen.XmlElement;
import net.peelmeagrape.hibernate.xmlgen.DefaultFromGenericType;
import net.peelmeagrape.hibernate.Column;

import java.lang.annotation.Retention;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Basic map key - using a value type.
 */
@Retention(RUNTIME)
@XmlElement(name="map-key")
public @interface SimpleMapKey
{
    /**
     * The foreign key column(s). Alternative to using a simple {@link #column()} configuration.
     */
    Column[] columnMapping() default {};

    /**
     * The name of the foreign key column. This may also be specified by nested {@link #columnMapping()} element(s).
     */
    @XmlAttribute String column() default "";
    @XmlAttribute String formula() default "";
    //todo: should be Class rather than String?
    @DefaultFromGenericType(0) @XmlAttribute String[] type() default {};
    @XmlAttribute int length() default 255;
    @XmlAttribute String node() default "";
}
